package co.fitstart.market.dao;

import com.demo2do.core.persistence.annotation.Dynamic;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.user.User;
import co.fitstart.entity.user.UserAccount;
import co.fitstart.entity.user.WechatAccount;

/**
 * 
 * @author dan
 *
 */
@Dynamic("hibernate")
public interface UserDao {
    
    /**
     * 
     * @param openid
     * @return
     */
    @Query("FROM User WHERE disabled = false AND openid = :openid")
    public User loadUser(@Variable("openid") String openid);
    
    /**
     * 
     * @param mobile
     * @return
     */
    @Query("FROM User WHERE disabled = false AND mobile = :mobile")
    public User loadUserByMobile(@Variable("mobile") String mobile);
    
    /**
     * 
     * @param name
     * @param value
     * @return
     */
    @Query("FROM UserAccount userAccount WHERE userAccount.name = :name AND userAccount.value = :value")
    public UserAccount loadUserAccount(@Variable("name") String name, @Variable("value") String value);
    
    /**
     * 
     * @param openid
     * @return
     */
    @Query("FROM WechatAccount WHERE openid = :openid")
    public WechatAccount loadWechatAccount(@Variable("openid") String openid);

}
